"""
 扑克
"""
import random
from enum import Enum


class Suite(Enum):
    SPADE, HEART, CLUB, DIAMOND = range(4)


class Card:

    def __init__(self, suite, face):
        self.suite = suite
        self.face = face

    def __lt__(self, other):
        if self.suite == other.suite:
            return self.face < other.face
        return self.suite.value < other.suite.value

    def __repr__(self):
        suite = ['♡', '♢', '♤', '♧']
        face = ['', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']

        return f'{suite[self.suite.value]}{face[self.face]}'


class Poker:

    def __init__(self):
        self.cards = [Card(suite, face)
                      for suite in Suite
                      for face in range(1, 14)]
        self.index = 0

    def shuffle(self):
        # index为已发派的派数
        self.index = 0
        random.shuffle(self.cards)

    def send(self):
        card = self.cards[self.index]
        self.index = 1
        return card

    @property
    def has_more(self):
        return self.index < len(self.cards)


class Player:

    def __init__(self, name):
        self.name = name
        self.cards = []

    def get_one(self, card):
        self.cards.append(card)

    def arrange(self):
        self.cards.sort()

def main():
    poker = Poker()
    poker.shuffle()
    players =[Player('东'),Player('东'),Player('东'),Player('东')]
    for _ in range(13):
        for player in players:
            if poker.has_more:
                card = poker.send()
                player.get_one(card)
    for player in players:
        player.arrange()
        print(f'{player.name}:',end='')

if __name__ == '__main__':
    main()
    